using System;

namespace GGEditor.API
{
	public class Command<T> : ICommand<T>
	{
		public Command()
		{
			IsDestructive = false;
		}

		#region Implementation of ICommand<T>

		public bool IsDestructive { get; set; }

		public string Description { get; set; }

		public ActionDelegate<T> Do { get; set; }

		public ActionDelegate<T> Undo { get; set; }

		ICommand<T> ICommand<T>.Do(T context)
		{
			Do(context);
			return new Command<T>()
			{
				Description = Description,
				Do = Undo,
				Undo = Do,
				IsDestructive = IsDestructive
			};
		}

		#endregion
	}

	public delegate void ActionDelegate<T>(T context);
}